<template>
    <div>
        <div class="title_box">
          <div class="iconfont icon-left" @click="$router.go(-1)"></div>
          <div class="title">注册</div>
          <div></div>
        </div>
        <div class="box">
            <div class="logo">LOGO</div>
            <div class="item">
                昵称：<input type="text" ref="username" >
            </div>
            <div class="item">
                账号：<input type="text" ref="userphone">
            </div>
            <div class="item">
                密码：<input type="password" ref="password">
            </div>
            <div class="item">
                确认密码：<input type="password" ref="verifypassword">
            </div>
            <div>
                <button class="register" @click="register">注册</button>
            </div>
        </div>
    </div>
</template>

<script>
import { Toast } from 'vant';
export default {
    data() {
        return {
        }
    },
    methods:{
        register(){
            let userData = {
                username: this.$refs.username.value,
                userphone: this.$refs.userphone.value,
                password: this.$refs.password.value
            }
            if(userData.userphone != "" && userData.password != "" && userData.password == this.$refs.verifypassword.value){
                this.$store.commit("adduser",userData)
                this.$router.push({path:"/login"})
            }else{
                Toast.fail('请正确输入账号密码');
            }
        },
    },
}
</script>

<style lang="less" scoped>
.box{
    width: 380px;
    margin: 0px auto;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -190px;
    margin-top: -200px;
    // border: 1px solid #333;

    .item{
        width: 100%;
        padding: 10px 0px;
        input{
            border: none;
            border-bottom: 1px solid #333;
            background: transparent;
        }
        &:nth-child(5) input{
            width: 250px;
        }
    }
    .logo{
        text-align: center;
        margin-bottom: 50px;
    }
    .register{
        margin-top: 50px;
        background: #3581FE;
        color: #fff;
        width: 100%;
        border: none;
        padding: 10px 0;
    }
}

    .title_box {
      height: 60px;
      line-height: 60px;
      padding: 7px 0px;
      text-align: center;
      background: #fff;
      border-bottom: 1px solid #E8E8E8;
      display: flex;
      justify-content: space-around;
      div:nth-child(odd){
          flex: 1;
          font-size: 18px;
      }
      .title {
        flex: 6;
        font-size: 20px;
      }
    }
</style>